﻿using Cloudthentic.SSIS.Server;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Configuration;
using Cloudthentic.SSIS.Server.Configuration;
using Microsoft.SqlServer.Dts.Runtime;

namespace Cloudthentic.SSIS.Server.Tests
{
    
    
    /// <summary>
    ///This is a test class for SsisApplicationTest and is intended
    ///to contain all SsisApplicationTest Unit Tests
    ///</summary>
    [TestClass()]
    public class SsisApplicationTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetConfiguration
        ///</summary>
        [TestMethod()]
        public void GetConfigurationTest()
        {
            SsisApplication_Accessor target = new SsisApplication_Accessor(); // TODO: Initialize to an appropriate value
            ConfigurationSection expected = null; // TODO: Initialize to an appropriate value
            ConfigurationSection actual;
            actual = target.GetConfiguration();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }


        [TestMethod()]
        public void WriteConfiguration()
        {

            Configuration.SsisServerConfiguration configuration = new SsisServerConfiguration();

            configuration.ServerHostName = "localhost";
            configuration.SsisPackages = new SsisPackageConfigurationElementCollection();
            
            Configuration.SsisPackageConfigurationElement element = new SsisPackageConfigurationElement();
            element.PackageName = "SsisPackage1";
            element.PackagePath = @".\Packages\Package1.dtsx";
            element.PackageConfigPath = "";

            configuration.SsisPackages.Add(element);


            System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);

            config.Sections.Add(typeof(Configuration.SsisServerConfiguration).Name, configuration);

            config.Save();

        }


        /// <summary>
        ///A test for GetReadOnlyConfiguration
        ///</summary>
        [TestMethod()]
        public void GetReadOnlyConfigurationTest()
        {
            SsisApplication_Accessor target = new SsisApplication_Accessor(); // TODO: Initialize to an appropriate value
            SsisServerConfiguration expected = null; // TODO: Initialize to an appropriate value
            SsisServerConfiguration actual;
            actual = target.GetReadOnlyConfiguration();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for Application
        ///</summary>
        [TestMethod()]
        public void ApplicationTest()
        {
            Application actual;
            actual = SsisApplication.Application;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
